package com.ygp.pool;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * <Description> <br>
 *
 * @author linmiaolai@sanyygp.com<br>
 * @version 1.0<br>
 * @date 2021/09/24 <br>
 */
public class ThreadPoolExecutorTest {

    private static final int COUNT_BITS = Integer.SIZE - 3;

    private static int ctlOf(int rs, int wc) {
        return rs | wc;
    }

    private static final int CAPACITY = (1 << COUNT_BITS) - 1;

    private static final int RUNNING = -1 << COUNT_BITS;
    private static final int SHUTDOWN = 0 << COUNT_BITS;
    private static final int STOP = 1 << COUNT_BITS;
    private static final int TIDYING = 2 << COUNT_BITS;
    private static final int TERMINATED = 3 << COUNT_BITS;

    private static int workerCountOf(int c) {
        return c & CAPACITY;
    }

    private static AtomicInteger ctl = new AtomicInteger(ctlOf(RUNNING, 0));

    public static void main(String[] args) {
        System.out.println(Integer.toBinaryString(RUNNING));
        System.out.println(SHUTDOWN);
        System.out.println(STOP);
        System.out.println(TIDYING);
        System.out.println(TERMINATED);

    }
}
